<template>
	<div id="newLOVDetails" class="newLOVDetails">
		<group>
			<x-input placeholder="类型(例如：S_LOV_ACTIVITY)" v-model="type"></x-input>
			<x-input placeholder="LOV值" v-model="value"></x-input>
		</group>

		<flexbox>
			<flexbox-item>
				<x-button class="flexBtn" type="primary" @click.native="createLOV">确定</x-button>
			</flexbox-item>
			<flexbox-item>
				<x-button class="flexBtn" type="warn" @click.native="cancel">取消</x-button>
			</flexbox-item>
		</flexbox>
	</div>
</template>

<script>
	import bus from '@/event/eventBus'
	import NetWorking from '../../../utils/networking'
	import {Group, XInput, XTextarea, XButton, Flexbox, FlexboxItem} from 'vux'

	const URL = 'list_of_value'
	export default {
		name: "new-list-of-value",
		components: {
			Group,
			XInput,
			XTextarea,
			XButton,
			Flexbox,
			FlexboxItem
		},
		data() {
			return {
				type: '',
				value: ''
			}
		},
		created: function () {
			bus.$emit("barController", 1)
			bus.$emit("setTopSimpleTitle", '新建LOV')
		},
		methods: {
			cancel: function () {
				this.$router.go(-1)
			},
			createLOV: function () {
				NetWorking.doPost(
					URL,
					null,
					{
						type: this.type,
						value: this.value
					}
				).then(
					response => {
						let rs = response.data
						if(rs.error_code == 0){
							this.$router.go(-1)
						}else{
							alert(rs.error_message)
						}
					}
				)
			}
		}
	}
</script>

<style>
	.newLOVDetails {
		border: solid;
		border-color: #f7f7fa;
		margin-left: 5px;
		margin-right: 5px;
		margin-top: 56px;
		box-shadow: 5px 5px 5px #888888;
		border-radius: 25px;
		background-color: white;
	}

	.buttonRole {
		width: 100%;
		margin-top: 15px;
		border-radius: 25px;
	}
</style>